<?php
namespace Admin\Controller;
use Think\Controller;
class LoginController extends Controller {
    public function index(){
    	echo md5('admin');
        $this->display();
    }
    /**
     * [checkdata 登录检测]
     * @Author   Xuebingsi
     * @DateTime 2017-02-04T11:42:12+0800
     * @return   [type]                   [description]
     */
    public function checkdata()
    {
    	$username = I('post.username');

        // var_dump(I('post.pass'));

    	$pass = md5(I('post.pass'));

    	$sql = "select * from admin where username='{$username}' and password = '{$pass}'";
    	// var_dump($sql);

    	$res = M()->query($sql);

    	if($res){

            

    		$_SESSION['username']=$res[0]['username'];
    		$_SESSION['id']=$res[0]['id'];

            $arr = array(
             'error'=>'0',
             'info'=>'登录成功'
             );
        }else{
            $arr = array(
             'error'=>'1',
             'info'=>'登录失败'
             );
        }

    	echo json_encode($arr);
    }
    public function loginout()
    {
    	session_unset();
    	session_destroy();
    	$this->success('退出成功',U('admin/login/index'),10);
    }

    public function out()
    {
        echo "请联系管理员开通权限";
    }
}